package cn.melon.view.control;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ButtonGroup;

import cn.melon.view.JImgButton;

/**
 * @ClassName: OnMouseOver
 * @author Hzy
 * 监听器，实现在鼠标移入/移出时按钮样式改变的功能
 */
public class OnMouseOver implements MouseListener{
	private JImgButton btn;
	private ButtonGroup btnGroup;

	
	public OnMouseOver(JImgButton btn,ButtonGroup btnGroup){
		this.btn = btn;
		this.btnGroup = btnGroup;
	}
	@Override
	public void mouseEntered(MouseEvent e){
//		鼠标进入按钮时重绘
		btn.repaintChangedButton();
	}
	@Override
	public void mouseExited(MouseEvent e){
//		鼠标离开时重绘
		btn.repaintOriginButton();
	}
	@Override
	public void mouseClicked(MouseEvent e){
//		鼠标点击时更改状态并重绘
		btnGroup.setSelected(btn.getModel(), false);
		btn.repaint();
	}
	@Override
	public void mouseReleased(MouseEvent e){
//		Do nothing
	}
	@Override
	public void mousePressed(MouseEvent e){
//		Do nothing
	}
}
